/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ru.jSky.matcher;

import java.util.Collection;
import org.hamcrest.CustomMatcher;
import org.hamcrest.Matcher;

/**
 *
 * @author Rakev
 */
public class AnyFromCollectionMatcher<T, C extends Collection<T>> extends CustomMatcher<C> {

    private Matcher<T> matcher;
    
    public AnyFromCollectionMatcher(Matcher<T> matcher) {
        super("");
        this.matcher = matcher;
    }

    @Override
    public boolean matches(Object items) {
        for (T item : (Collection<T>) items){
            if (matcher.matches(item))
                return true;
        }
        return false;
    }
    
}
